package com.zll.feign;

import com.zll.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {


    @Override
    public UserService create(Throwable throwable) {
        // 打印接口错误
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getUserById(Long id) {
                return new User(-1L,"熔断触发","当前服务器不可使用，请稍后重试吧！");
            }
        };
    }
}
